﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using OilRigSumoWrestlers.Actions;
using OilRigSumoWrestlers.Controllables;
using OilRigSumoWrestlers.Controllables.Controllers;
using OilRigSumoWrestlers.Controllables.GameModes;
using OilRigSumoWrestlers.Levels;
using OilRigSumoWrestlers.Scenes;
using RaptorEngine;
using RaptorEngine.Components;
using RaptorEngine.Components.CollidableComponent;
using RaptorEngine.Components.Drawable;
using RaptorEngine.Managers;

namespace OilRigSumoWrestlers.Entities.MenuItems
{
    class SingleplayerItem : MenuItem
    {
        public SingleplayerItem(DrawableText selectedText, DrawableText deselectedText)
            : base(selectedText, deselectedText) { }

        public override void Execute()
        {
            GameEngine.Instance.Scene.HideCurrentScene();
            GameEngine.Instance.Scene.StopCurrentScene();

            
            
            // Level design
            ALevel level = new LevelTest();

            // Player
            PlayerCharacter player = new PlayerCharacter("Models/Characters/player1");
            player.Position = new Vector3(20, 20, 10);
            player.AddComponent(new HumanControllable(player, LogicalPlayerIndex.One));
            
            // AI
            PlayerCharacter ai = new PlayerCharacter("Models/Characters/player2");
            ai.Position = new Vector3(20, 20, 30);
            ai.AddComponent(new AIControllable(ai, player, level));

            // Add players to level
            player.Position = level.GetPlayer1StartPosition();
            ai.Position = level.GetPlayer2StartPosition();

            //player.AddComponent(new AIControllable(player, ai, level));

            // Game Mode
            Entity gamemode = new Entity();
            KnockoutMode ko = new KnockoutMode(gamemode, player, ai, -20f, 3, level);
            gamemode.AddComponent(ko);
            

            GameEngine.Instance.Scene.PushScene(new LevelScene(player, ai,level,gamemode, false));
            GameEngine.Instance.Scene.ShowCurrentScene();

            GameEngine.Instance.Scene.PushScene(new CountdownScene());
            
            GameEngine.Instance.Scene.StartCurrentScene();
            GameEngine.Instance.Scene.ShowCurrentScene();




        }
    }
}
